package com.his.system.manager.task;

import com.alibaba.fastjson.JSONObject;

import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

/**
 * TaskThread
 *
 * @Description
 * @Author HHJ
 * @Date 2020-07-25 17:08
 */

public class TaskThread extends Timer {
    private static final JdbcUserDao userDao = new JdbcUserDao();

    /**
     * start
     *
     * @param date         指定时间
     * @param periodSecond 时间间隔
     */
    public void start(Date date, long periodSecond) {

        TaskThread timer = new TaskThread();
        //安排指定的任务在指定的时间开始进行重复的固定延迟执行。
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                Date executeTime = new Date(this.scheduledExecutionTime());
                List<EntryRecord> userDtos = userDao.getEntryRecordList(0,10);
                System.out.println("本次任务执行的时间是" + executeTime + "---测试:" + userDtos.size() + "-----结果:" + JSONObject.toJSONString(userDtos));

            }
        }, date, periodSecond * 1000L);
    }
}